Skip to content

Fix core-state poll logs and rewards timeout UX#1321

Open
jwalin-shah wants to merge 1 commit intotinyhumansai:mainfrom
jwalin-shah:codex/SYM-209-core-state-rewards-timeout
Open

Fix core-state poll logs and rewards timeout UX#1321
jwalin-shah wants to merge 1 commit intotinyhumansai:mainfrom
jwalin-shah:codex/SYM-209-core-state-rewards-timeout

Conversation

@jwalin-shah
Copy link
Copy Markdown
Contributor

@jwalin-shah jwalin-shah commented May 7, 2026

Summary

  • Rate-limit core-state poll warnings so repeated bootstrap failures log at useful checkpoints instead of every poll.
  • Keep detailed debug('core-state') failure diagnostics for development without console warning spam.
  • Add a shorter /rewards/me request timeout and normalize timeout-style failures into an actionable retry message.
  • Preserve rewards success normalization and backend failure behavior with focused tests.

Problem

  • Startup can emit repeated [core-state] poll failed warnings while the core state endpoint is unavailable.
  • /rewards/me timeout-style failures can surface as low-level network/client errors instead of a quiet, recoverable Rewards state.

Solution

  • Added shouldWarnForBootstrapFailure() and use it to warn on attempts 1, 5, then every 5 failures thereafter while debug logs still include every failed attempt.
  • Wrapped rewardsApi.getMyRewards() request/failure handling to apply a 15s timeout and map timeout/abort/ERR_TIMED_OUT messages to: “Rewards request timed out. Please check your connection and try again.”
  • Updated provider and rewards API tests for warning checkpoint behavior, existing success behavior, backend failures, and timeout mapping.

Submission Checklist

  • Tests added or updated (happy path + at least one failure / edge case) per docs/TESTING-STRATEGY.md
  • Diff coverage ≥ 80% — CI diff-cover is authoritative and is running on this PR; focused changed-line tests passed locally.
  • Coverage matrix updated — N/A: behavior-only change to existing core-state/rewards flows.
  • All affected feature IDs from the matrix are listed in the PR description under ## Related — N/A: no feature ID row changed.
  • No new external network dependencies introduced (mock backend used per docs/TESTING-STRATEGY.md)
  • Manual smoke checklist updated if this touches release-cut surfaces — N/A: no release smoke checklist behavior changed.
  • Linked issue closed via Closes #NNN in the ## Related section

Impact

  • Runtime impact is limited to the React app provider and rewards API client.
  • No Rust/core behavior changes.
  • Rewards timeout failures remain recoverable through the existing Rewards retry UI.

Related


AI Authored PR Metadata (required for Codex/Linear PRs)

Linear Issue

Commit & Branch

  • Branch: codex/SYM-209-core-state-rewards-timeout
  • Commit SHA: f113824af973abb8977bbd92cd8ae45ed69da3bb

Validation Run

  • pnpm --filter openhuman-app format:check (via pre-push hook; passed)
  • pnpm typecheck / pnpm --filter openhuman-app compile (passed)
  • Focused tests: pnpm --dir app exec vitest run src/providers/__tests__/CoreStateProvider.test.tsx src/services/api/__tests__/rewardsApi.test.ts --config test/vitest.config.ts (13 passed)
  • Rust fmt/check (if changed): cargo fmt --manifest-path ../Cargo.toml --all --check (via pre-push hook; passed); cargo check --manifest-path src-tauri/Cargo.toml (via pre-push hook; passed with pre-existing warnings)
  • Tauri fmt/check (if changed): cargo fmt --manifest-path src-tauri/Cargo.toml --all --check and cargo check --manifest-path src-tauri/Cargo.toml (via pre-push hook; passed with pre-existing warnings)

Validation Blocked

  • command: N/A
  • error: N/A
  • impact: N/A

Behavior Changes

  • Intended behavior change: core-state polling warnings are deduped/rate-limited; rewards timeout errors become actionable retry guidance.
  • User-visible effect: Rewards remains in a quiet fallback state with existing Try again recovery when /rewards/me times out.

Parity Contract

  • Legacy behavior preserved: rewards success payload normalization and backend failure propagation remain covered.
  • Guard/fallback/dispatch parity checks: timeout/abort/network timeout mapping added without changing core RPC or onboarding/OAuth flows.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): none found for this fresh branch.
  • Canonical PR: this PR.
  • Resolution (closed/superseded/updated): N/A

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Warning

Rate limit exceeded

@jwalin-shah has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 47 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a0684d62-fcbd-4593-acbb-156b9c14968c

📥 Commits

Reviewing files that changed from the base of the PR and between 09f8f12 and f113824.

📒 Files selected for processing (4)
  • app/src/providers/CoreStateProvider.tsx
  • app/src/providers/__tests__/CoreStateProvider.test.tsx
  • app/src/services/api/__tests__/rewardsApi.test.ts
  • app/src/services/api/rewardsApi.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jwalin-shah jwalin-shah marked this pull request as ready for review May 7, 2026 06:24
@jwalin-shah jwalin-shah requested a review from a team May 7, 2026 06:24
@oxoxDev
Copy link
Copy Markdown
Contributor

oxoxDev commented May 7, 2026

Tested locally on a merge of upstream/main into this branch (cold-boot needs #1324's redux-persist localStorage adapter; without it the dev host throws storage.getItem is not a function and renders white screen).

Verdict: works as intended

AC Status Evidence
AC1 — no repeated [core-state] poll failed PASS Console shows warns at attempts 1, 5, 10, 15 only — throttle confirmed via shouldWarnForBootstrapFailure
AC2 — regression safety PASS rewardsApi.test.ts 5/5 + CoreStateProvider.test.tsx 8/8 green
AC4 — graceful failure, no retry storm PASS After 15s timeout, Rewards page flips to a yellow warning banner with the new copy + manual "Try again" button. No auto-retry. Page degrades to Discord connect cards + "Rewards sync pending" empty state
AC5 — useful reason/status, no noisy repetition PASS Throttled warns carry sanitized error {message: "Failed to fetch"}; [rewards] backend snapshot unavailable debug fires once per attempt

Repro for the timeout path: monkey-patched window.fetch to honor AbortSignal and hang forever on /rewards/me — at 15s the AbortController fires, isTimeoutError matches AbortError, friendly copy reaches the UI.

Action item before merge

Branch needs upstream/main merged in (or rebased) so #1324 lands here — otherwise the dev-host cold-boot crash blocks anyone who tries to test or run CI. Without that, the white-screen blocks even reaching the Rewards page.

(Tried to push the merge commit on your behalf via maintainer-edits but lacked write access to your fork — leaving it to you.)

Copy link
Copy Markdown
Member

@senamakel senamakel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls see above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Core state polling and rewards API request time out in the app console

4 participants